package com.faiz.algorithm;

import java.util.ArrayList;
import java.util.List;

public class MaxOrderByAscSequence {

    public static List<Integer> solution(int[] array) {
        if (array == null || array.length == 0) {
            return null;
        }
        List<List<Integer>> list = new ArrayList<>();
        List<Integer> numList = new ArrayList<>();
        numList.add(Integer.valueOf(array[0]));
        list.add(numList);
        for (int i = 1; i <  array.length; i++ ) {
            for (List<Integer> tmpList : list) {
                if (tmpList.get(tmpList.size() - 1) < array[i]) {
                    tmpList.add(array[i]);
                } else {
                    List<Integer> newList = new ArrayList<>();
                    newList.add(Integer.valueOf(array[i]));
                }
            }
        }
        List<Integer> result = new ArrayList<>();
        int maxLength = 0;
        for (List<Integer> itList : list) {
            if (maxLength < itList.size()) {
                result = itList;
            }
        }

        return result;
    }
}
